Crate eng_fmt

source ·
Expand description

Module containing trait to format f64 in engineering notation.

Examples

use eng_fmt::FormatEng;
let x: f64 = 0.010;
let expected = "10.0e-3".to_string();
assert_eq!(x.format_eng(None), expected);
use eng_fmt::FormatEng;
let x = std::f64::consts::PI;
let expected = "3.142".to_string();
assert_eq!(x.format_eng(Some(4)), expected);
use eng_fmt::FormatEng;
let x = 6.022e-23;
let expected = "60.2e-24".to_string();
assert_eq!(x.format_eng(None), expected);

Traits

Functions